home *** CD-ROM | disk | FTP | other *** search
/ Network Support Library / RoseWare - Network Support Library.iso / logbatch / short.exe / SHORTE.INC < prev   
Text File  |  1993-07-04  |  1KB  |  34 lines

  1. ; This routine expects three DOS environment variables: 
  2. ;   LONG, LENGTH, TRUNCATE.
  3. ;   LONG  contains original string
  4. ;   SHORT on exit contains LENGTH characters of LONG,
  5. ;   either by TRUNCATE on the LEFT or on the RIGHT, depending on the 
  6. ;   setting of TRUNCATE.
  7. ;
  8. ;   This code is a modification of HOMMAP.INC and is inspired by SHORTEN.EXE 
  9. ;   and has been lightly tested under nw3.11 from msdos 5.0.  
  10. ;   It is intended to be used a bit like a subroutine.
  11.  
  12. TEMP SET WORKSTR = "<%LONG>"
  13. TEMP SET COUNTER = "0"
  14. ; Count length of LONG
  15. COUNTLOOP:
  16. IF <WORKSTR> == "" THEN GOTO COUNTDONE
  17. TEMP SET COUNTER = <COUNTER> + "1"
  18. TEMP SET WORKSTR = <WORKSTR> >> 1
  19. GOTO COUNTLOOP
  20. COUNTDONE:
  21. ; Check to see if length is more than LENGTH
  22. SET SHORT="<%LONG>"
  23. IF VALUE <COUNTER> <= VALUE <LENGTH> THEN GOTO TRUNCDONE
  24. ; Yes, it's more than LENGTH, chop it off
  25. TEMP SET COUNTER = <COUNTER> - <LENGTH>
  26. TRUNCLOOP:
  27. IF VALUE <COUNTER> == "0" THEN GOTO TRUNCDONE
  28. TEMP SET COUNTER = <COUNTER> - "1"
  29. if <TRUNCATE>=="LEFT" SET SHORT= "%<SHORT>" << 1
  30. if <TRUNCATE>=="RIGHT" SET SHORT="%<SHORT>" >> 1
  31. GOTO TRUNCLOOP
  32. TRUNCDONE:
  33. ; Now SHORT has been shorten to LENGTH characters or less
  34.